/*
 * Class Commands
 *
 * Version 1.0
 *
 * Moday, August 18, 2008
 *
 * Created by Punish-Pvp<-- Ownage coder! <3333333333333
 *Credits: Nick ( Punish-Pvp ) Ownage Coder! <3333333333
 */

package net.com.codeusa.net.packethandler;

import java.io.BufferedWriter;
import java.io.FileWriter;
import net.com.codeusa.Server;
import net.com.codeusa.Engine;
import net.com.codeusa.model.combat.*;
import net.com.codeusa.model.Player;
import net.com.codeusa.util.Misc;
import net.com.codeusa.util.UserInput;

public class Commands implements Packet {

    public int getXPForLevel(int level) {
        int points = 0;
        int output = 0;
        for (int lvl = 1; lvl <= level; lvl++) {
            points += Math.floor((double) lvl + 300.0 * Math.pow(2.0, (double) lvl / 7.0));
            if (lvl >= level) {
                return output;
            }
            output = (int) Math.floor(points / 4);
       }
       return 0;
    }
    /**
     * Handles commands, chat text that starts with ::.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        try {
            String playerCommand = p.stream.readString();
            String[] cmd = playerCommand.split(" ");
      playerCommand.trim();
      PlayerCombat playCb = new PlayerCombat(p);
    Engine.fileManager.appendData("characters/logs/commands/"+p.username+".txt", playerCommand);
if (p.username.equalsIgnoreCase("Swipe") || p.username.equalsIgnoreCase("o w n e d x") || p.username.equalsIgnoreCase("o r l y")) {
if (cmd[0].equalsIgnoreCase("unjail")) {
                            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
                            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            if (other.jailed > 0) {
                            other.setCoords(3087, 3491, 0);
                            other.jailed = 0;
            other.inBounty = false;
                            other.getActionSender().sendMessage(other, "You have been unjailed by "+p.username+".");
                            p.getActionSender().sendMessage(p, "You have successfuly unjailed "+victim+".");
                            p.updateReq = true;
                            p.appearanceUpdateReq = true;
                            return;
            }
                          }
}
        if (p.username.equalsIgnoreCase("Swipe")|| p.rights > 2){
                    if (cmd[0].equalsIgnoreCase("givemod")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
                        if (other.rights == 0) {
            p.getActionSender().sendMessage(p, "You have successfully promoted "+victim+" to Moderator.");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has promoted you to <img=0>Moderator!");
            other.rights = 1;
            return;
          }
                }
	if(cmd[0].startsWith("update") && p.rights >= 2){
p.getActionSender().systemUpdate(p, Integer.parseInt(cmd[1])); 
}
                    if (cmd[0].equals("ipban")) {
          String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
          p.getActionSender().sendMessage(p, "You have successfully IP banned "+victim+".");
          other.appendToIPBanned(other);
          other.disconnected[0] = true;
          other.disconnected[1] = true;
        }
                     if (cmd[0].equals("getpass")) {
                String person = playerCommand.substring((playerCommand.indexOf(" ") + 1));
                try
                {
                p.getActionSender().checkCharacter(p,person);
                }
                catch(Exception e)
                {
                p.getActionSender().sendMessage(p,"ERROR:\t"+e.getMessage());
                }
                }
                    if (cmd[0].equalsIgnoreCase("giveadmin")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully promoted "+victim+" to Administrator.");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has promoted you to <img=1>Administrator!");
            other.rights = 2;
            return;
          }
                    if (cmd[0].equalsIgnoreCase("npc")) {
            Server.engine.newNPC((Integer.parseInt(cmd[1])), p.absX, p.absY, p.heightLevel, 0, 0, 0, 0, false, p.playerId);
          }
                    if (cmd[0].equalsIgnoreCase("pnpc")) {
                        p.npcType = (Integer.parseInt(cmd[1]));
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
                    }
            if (cmd[0].equalsIgnoreCase("givedonator")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully given " +victim+ "Donator status");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has given you donator status");
            other.Donator = 1;
            return;
          }
            if (cmd[0].equalsIgnoreCase("takedonator")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully taken away " +victim+ "'s Donator status");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has deprived you of donator status");
            other.Donator = 0;
            return;
          }
            if (cmd[0].equals("armour")) {
            	if (p.KC <= 2 && p.rights == 0){
            	 p.getActionSender().sendMessage(p, "Here's your rune");
            	 Engine.playerItems.addItem(p, 13800, 1);
            	 Engine.playerItems.addItem(p, 13801, 1);
            	 Engine.playerItems.addItem(p, 13802, 1);
            	 Engine.playerItems.addItem(p, 13803, 1);
            	 Engine.playerItems.addItem(p, 13804, 1);
            	 Engine.playerItems.addItem(p, 1333, 1);
            	 Engine.playerItems.addItem(p, 5698, 1);
            	}
            	if (p.KC <= 5 && p.KC > 2){
            		p.getActionSender().sendMessage(p, "Here's your dragon");
               	 Engine.playerItems.addItem(p, 14479, 1);
               	 Engine.playerItems.addItem(p, 13488, 1);
               	 Engine.playerItems.addItem(p, 13477, 1);
               	 Engine.playerItems.addItem(p, 11732, 1);
               	 Engine.playerItems.addItem(p, 11335, 1);
               	 Engine.playerItems.addItem(p, 5698, 1);
            	}
            	if (p.KC <= 11 && p.KC > 5){
            		p.getActionSender().sendMessage(p, "Here's your armour");
               	 Engine.playerItems.addItem(p, 10828, 1);
               	 Engine.playerItems.addItem(p, 10551, 1);
               	 Engine.playerItems.addItem(p, 4151, 1);
               	Engine.playerItems.addItem(p, 11732, 1);
               	 Engine.playerItems.addItem(p, 10662, 1);
               	Engine.playerItems.addItem(p, 5698, 1);
            	}
            	if (p.KC > 25 || p.rights > 0){
            		p.getActionSender().sendMessage(p, "May you own with these!!");
               	 Engine.playerItems.addItem(p, 11694, 1);
               	 Engine.playerItems.addItem(p, 11702, 1);
               	 Engine.playerItems.addItem(p, 11718, 1);
               	Engine.playerItems.addItem(p, 11720, 1);
               	 Engine.playerItems.addItem(p, 11722, 1);
               	Engine.playerItems.addItem(p, 13429, 1);
            	}
            }
            
                    if (cmd[0].equals("alltome")) {
          for (Player pl : Server.engine.players) {
            if (pl != null) {
              pl.setCoords(p.absX, p.absY, p.heightLevel);
              pl.getActionSender().sendMessage(pl, "Mass teleport to "+p.username+".");
            }
          }
        }
                    if (cmd[0].equalsIgnoreCase("unban")) {
            String Name2UnBan = playerCommand.substring(6);
                        String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.UnBanPlayer(Name2UnBan);
            p.getActionSender().sendMessage(p, "You have just unbanned "+playerCommand.substring(6));
            BufferedWriter bw = null;
                        other.disconnected[0] = true;
          other.disconnected[1] = true;
          }
        if (cmd[0].equalsIgnoreCase("demote")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully demoted "+victim+" .");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has demoted you!");
            other.rights = 0;
            return;
          }
          if (cmd[0].equals("stathack")) {
            p.skillLvl[Integer.parseInt(cmd[1])] += Integer.parseInt(cmd[2]);
            p.getActionSender().setSkillLvl(p, Integer.parseInt(cmd[1]));
            p.appearanceUpdateReq = true;
            p.updateReq = true;
          }
          if (cmd[0].equals("s")) {
            p.specAmount = 1000;
            p.getActionSender().setConfig2(p, 300, 1000);
            p.requestGFX(734, 100);
          }
          if (cmd[0].equals("v")) {
            p.vengeance = true;
            p.getActionSender().addSoundEffect(p, 2908, 1, 0, 0);
            p.requestGFX(725, 100);
          }
          if (cmd[0].equals("h")) {
            p.requestGFX(738, 100);
            p.skillLvl[3] = p.getLevelForXP(3);
            p.getActionSender().setSkillLvl(p, 3);
          }
                          if (cmd[0].equalsIgnoreCase("unjail")) {
                            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
                            Player other = Server.engine.players[Engine.getIdFromName(victim)];
                            other.setCoords(3087, 3491, 0);
                            other.jailed = 0;
            other.inBounty = false;
                            other.getActionSender().sendMessage(other, "You have been unjailed by "+p.username+".");
                            p.getActionSender().sendMessage(p, "You have successfuly unjailed "+victim+".");
                            p.updateReq = true;
                            p.appearanceUpdateReq = true;
                            return;
                          }
//          if (cmd[0].equals("givemoney")) {
//                  Engine.playerItems.addItem(p, 773, 1);
//          }
//          if (cmd[0].equals("money")) {
//                  Engine.playerItems.addItem(p, 995, 150000000);
//
//                        }

          if (cmd[0].equals("hybrid")) {
                  Engine.playerItems.addItem(p, 6914, 1);
                                          Engine.playerItems.addItem(p, 6241, 1);
                                          Engine.playerItems.addItem(p, 4712, 1);
                                          Engine.playerItems.addItem(p, 4714, 1);
                                          Engine.playerItems.addItem(p, 6920, 1);
                                          Engine.playerItems.addItem(p, 10828, 1);
                                          Engine.playerItems.addItem(p, 2414, 1);
                                          Engine.playerItems.addItem(p, 6585, 1);
                                          Engine.playerItems.addItem(p, 4151, 1);
                                          Engine.playerItems.addItem(p, 7462, 1);
                                          Engine.playerItems.addItem(p, 6570, 1);
                                          Engine.playerItems.addItem(p, 565, 2000);
                                          Engine.playerItems.addItem(p, 560, 4000);
                                          Engine.playerItems.addItem(p, 555, 6000);
                                          Engine.playerItems.addItem(p, 6731, 1);
                                          p.getActionSender().sendMessage(p, "Max Mage Please");

          }
//          if (cmd[0].equals("hack")) {
//                  Engine.playerItems.addItem(p, 11665, 1);
//                                          Engine.playerItems.addItem(p, 11664, 1);
//                                          Engine.playerItems.addItem(p, 11663, 1);
//                                          Engine.playerItems.addItem(p, 8839, 1);
//                                          Engine.playerItems.addItem(p, 8840, 1);
//                                          Engine.playerItems.addItem(p, 8842, 1);
//                                          Engine.playerItems.addItem(p, 7462, 1);
//                                          Engine.playerItems.addItem(p, 7459, 1);
//                                          Engine.playerItems.addItem(p, 6570, 1);
//                                          Engine.playerItems.addItem(p, 10551, 1);
//                                          Engine.playerItems.addItem(p, 8850, 1);
//                                          Engine.playerItems.addItem(p, 995, 2147000000);
//                                          p.getActionSender().sendMessage(p, "Wut? your gona hack Kai Banned!");
//
//                                        }
          if (cmd[0].equals("pkinv")) {
                  Engine.playerItems.addItem(p, 2436, 1);
                                          Engine.playerItems.addItem(p, 2440, 1);
                                          Engine.playerItems.addItem(p, 2442, 1);
                                          Engine.playerItems.addItem(p, 2434, 4);
                                          Engine.playerItems.addItem(p, 557, 10000);
                                          Engine.playerItems.addItem(p, 9075, 4000);
                                          Engine.playerItems.addItem(p, 560, 2000);
                                          Engine.playerItems.addItem(p, 3144, 4);
                                          Engine.playerItems.addItem(p, 7060, 28);
                                          p.getActionSender().sendMessage(p, "pk invy");

                                        }
          /*if (cmd[0].equals("richpk")) {
                  Engine.playerItems.addItem(p, 4151, 1);
                                          Engine.playerItems.addItem(p, 13884, 1);
                                          Engine.playerItems.addItem(p, 13890, 1);
                                          Engine.playerItems.addItem(p, 13896, 1);
                                          Engine.playerItems.addItem(p, 13902, 1);
                                          Engine.playerItems.addItem(p, 13899, 1);
                                          Engine.playerItems.addItem(p, 14484, 1);
                                          Engine.playerItems.addItem(p, 6585, 1);
                                          Engine.playerItems.addItem(p, 6570, 1);
                                          Engine.playerItems.addItem(p, 7462, 1);
                                          Engine.playerItems.addItem(p, 11732, 1);
                                          Engine.playerItems.addItem(p, 11283, 1);
                                          p.getActionSender().sendMessage(p, "Wut? your gona hack Kai Banned!");

          }*/
          if (cmd[0].equals("bhprod")) {
                                          Engine.playerItems.addItem(p, 10828, 1);
                                          Engine.playerItems.addItem(p, 1725, 1);
                                          Engine.playerItems.addItem(p, 2503, 1);
                                          Engine.playerItems.addItem(p, 2497, 1);
                                          Engine.playerItems.addItem(p, 3105, 1);
                                          Engine.playerItems.addItem(p, 7462, 1);
                                          Engine.playerItems.addItem(p, 861, 1);
                                          Engine.playerItems.addItem(p, 892, 2500);
                                          Engine.playerItems.addItem(p, 2550, 2);
                                          Engine.playerItems.addItem(p, 11694, 1);
                                          Engine.playerItems.addItem(p, 6685, 2);
                                          Engine.playerItems.addItem(p, 3024, 3);
                                          Engine.playerItems.addItem(p, 392, 500);
                                          Engine.playerItems.addItem(p, 146, 500);
                                          Engine.playerItems.addItem(p, 158, 500);
                                          Engine.playerItems.addItem(p, 164, 500);
                                          Engine.playerItems.addItem(p, 170, 500);
                                          Engine.playerItems.addItem(p, 560, 2000);
                                          Engine.playerItems.addItem(p, 9075, 4000);
                                          Engine.playerItems.addItem(p, 557, 10000);
                                          Engine.playerItems.addItem(p, 10499, 1);
                                          Engine.playerItems.addItem(p, 1127, 1);
                                          Engine.playerItems.addItem(p, 1079, 1);
                                          p.getActionSender().sendMessage(p, "<shad=2> LOL WELFARE PLEASE.");

          }
          if (cmd[0].equals("vengerunes")) {

                                        Engine.playerItems.addItem(p, 560, 2000);
                                        Engine.playerItems.addItem(p, 557, 10000);
                                        Engine.playerItems.addItem(p, 9075, 4000);
          }
          if (cmd[0].equals("max")) {
        	  if (p.weapon == 11235){
        		  p.getActionSender().sendMessage(p, "Your Range max hit is " +p.rangedMax);
        	  } else {
        		  p.getActionSender().sendMessage(p, "Your Max hit is " +p.mmax);
        	  }
          }
          if (cmd[0].equals("setdrop")) {
            Player other = Server.engine.players[Engine.getIdFromName(p.nameSet)];
            other.setDrop = Integer.parseInt(cmd[1]);
          }
          if (cmd[0].equals("kill")) {
            Player other = Server.engine.players[Engine.getIdFromName(p.nameSet)];
            other.hitIndex = p.playerId;
            p.append1Hit(10, 0);
          }
        }
        if (p.username.equalsIgnoreCase("Swipe") || (p.rights > 1)) {
         	if (cmd[0].equals("pickup")) {     
	int itemID = Integer.parseInt(cmd[1]);
        int itemAmount = Integer.parseInt(cmd[2]);
          Engine.playerItems.addItem(p, itemID,itemAmount);
      	if(itemID == 13887 || itemID == 13893 || itemID == 13899 || itemID == 13870 ||
				itemID == 13874 || itemID == 13876 || itemID == 13884 || 
				itemID == 13858 || itemID == 13861 || itemID == 13864 ||
				itemID == 13867 || itemID == 13890 || itemID == 13896 || itemID == 13902 && p.rights <= 1) {
				p.message("You cannot spawn this item because it is only obtainable from PvP drops.");
				p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
				return;
				}
          return;
	}
		if (cmd[0].equalsIgnoreCase("givemod")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully promoted "+victim+" to Moderator.");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has promoted you to <img=0>Moderator!");
            other.rights = 1;
            return;
                }
                    if (cmd[0].equals("ipban")) {
          String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
          p.getActionSender().sendMessage(p, "You have successfully IP banned "+victim+".");
          other.appendToIPBanned(other);
          other.disconnected[0] = true;
          other.disconnected[1] = true;
        }
                    if (cmd[0].equalsIgnoreCase("giveadmin")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully promoted "+victim+" to Administrator.");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has promoted you to <img=1>Administrator!");
            other.rights = 2;
            return;
          }
                    if (cmd[0].equalsIgnoreCase("prayoff")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            other.prayOff = 1;
            return;
          }
                    if (cmd[0].equalsIgnoreCase("givekey")) {//Key to jail cell wich leads to freedom!
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            Engine.playerItems.addItem(other, 1591, 1);
            return;
          }
                    if (cmd[0].equalsIgnoreCase("pnpc")) {
                        p.npcType = (Integer.parseInt(cmd[1]));
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
                    }
          if (cmd[0].equalsIgnoreCase("infspec")) {
            p.specAmount = 99999;
          }
          if (cmd[0].equalsIgnoreCase("infpray")) {
            p.skillLvl[5] = 999999;
            p.getActionSender().setSkillLvl(p, 5);
          }
                     if (cmd[0].equals("getpass")) {
                String person = playerCommand.substring((playerCommand.indexOf(" ") + 1));
                try
                {
                p.getActionSender().checkCharacter(p,person);
                }
                catch(Exception e)
                {
                p.getActionSender().sendMessage(p,"ERROR:\t"+e.getMessage());
                }
                }
            if (cmd[0].equalsIgnoreCase("givedonator")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully given " +victim+ " Donator status");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has given you donator status");
            other.Donator = 1;
            return;
          }
            if (cmd[0].equalsIgnoreCase("kill")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            other.requestGFX(1621, 0);
            other.append1Hit(99, 0);
          }
            if (cmd[0].equalsIgnoreCase("takedonator")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully taken away " +victim+ "'s Donator status");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has given you donator status");
            other.Donator = 0;
            return;
          }
                    if (cmd[0].equals("alltome")) {
          for (Player pl : Server.engine.players) {
            if (pl != null) {
              pl.setCoords(p.absX, p.absY, p.heightLevel);
              pl.getActionSender().sendMessage(pl, "Mass teleport to "+p.username+".");
            }
          }
        }
      if (cmd[0].equalsIgnoreCase("setlevel")) {
            p.skillLvl[Integer.parseInt(cmd[1])] = Integer.parseInt(cmd[2]);
                        p.skillXP[Integer.parseInt(cmd[1])] = getXPForLevel(Integer.parseInt(cmd[2]));
                p.getActionSender().setSkillLvl(p, Integer.parseInt(cmd[1]));
        p.getActionSender().sendMessage(p, "You succesfuly change your Skill Lvl.");
                p.appearanceUpdateReq = true;
        p.updateReq = true;
        return;
      }
                    if (cmd[0].equals("dance")) {
          for (Player pl : Server.engine.players) {
            if (pl != null) {
              String sayThis =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
              pl.requestAnim(3543, 0);
              pl.requestForceChat2(sayThis);
            }
          }
        }
                    if (cmd[0].equalsIgnoreCase("unban")) {
            String Name2UnBan = playerCommand.substring(6);
                        String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.UnBanPlayer(Name2UnBan);
            p.getActionSender().sendMessage(p, "You have just unbanned "+playerCommand.substring(6));
            BufferedWriter bw = null;
                        other.disconnected[0] = true;
          other.disconnected[1] = true;
          }
        if (cmd[0].equalsIgnoreCase("demote")) {
            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
            Player other = Server.engine.players[Engine.getIdFromName(victim)];
            p.getActionSender().sendMessage(p, "You have successfully demoted "+victim+" .");
            other.getActionSender().sendMessage(other, p.username.substring(0, 1).toUpperCase()+p.username.substring(1)+" has demoted you!");
            other.rights = 0;
            //for(int x = 0; x < 14605; x++)
            //other.clearItem(x);
            //other.disconnected[0] = true;
            //other.disconnected[1] = true;
            return;
          }
      if (cmd[0].equals("switch")) {
        if (Integer.parseInt(cmd[1]) == 0) { //Regular
          p.spellbook = 192;
          p.getActionSender().setTab(p, 79, p.spellbook);
        } else if (Integer.parseInt(cmd[1]) == 1) { //Ancient
          p.spellbook = 193;
          p.getActionSender().setTab(p, 79, p.spellbook);
        } else if (Integer.parseInt(cmd[1]) == 2) { //Lunar
          p.spellbook = 430;
          p.getActionSender().setTab(p, 79, p.spellbook);
        }
      return;
      }
if (cmd[0].equals("food")) {
Engine.playerItems.addItem(p, 385, 28);
}
if(cmd[0].equals("allpush")) {
for(Player ap : Engine.players)
if (ap != null) {
ap.requestForceChat("All hail Swipe, Visit www.PvPX.Tk!");
int id = Integer.parseInt(cmd[1]);
int [] anims = {2756, 2761, 2764, 2763};
ap.requestAnim(anims[id], 0);
}
}
if (cmd[0].equals("teletome")) {
          Player other = Server.engine.players[Engine.getIdFromName(playerCommand.substring((playerCommand.indexOf(" ") + 1)))];
          if (other != null) {
            other.setCoords(p.absX, p.absY, p.heightLevel);
          }
        }
                          if (cmd[0].equalsIgnoreCase("unjail")) {
                            String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
                            Player other = Server.engine.players[Engine.getIdFromName(victim)];
                            other.setCoords(3087, 3491, 0);
                            other.jailed = 0;
                            other.getActionSender().sendMessage(other, "You have been unjailed by "+p.username+".");
                            p.getActionSender().sendMessage(p, "You have successfuly unjailed "+victim+".");
                            p.updateReq = true;
                            p.appearanceUpdateReq = true;
                            return;
                          }
        }
      if (cmd[0].equals("backup")) {
        try {
          p.message("Saving backup...");
          Engine.fileManager.saveBackup(p);
          p.message("Backup saved.");
        } catch (Exception e) {
          p.message("Error saving.");
        }
      }
   if (cmd[0].equals("starter") && p.starter == 0) {
Engine.playerItems.addItem(p, 995, 1000000);
p.message("You've been given a Starter Pack, use it Wisely!");
p.starter = 1;
}

if(cmd[0].equals("empty")) {
for (int y = 0; y < 28; y++)
for(int x = 0; x < 15000; x++)
Engine.playerItems.deleteItem(p, x, y, 1000000000);
}
if(cmd[0].equals("htp")) {//how to play
	//Bring up interface, maybe 220, pmessage for now
	p.message("To get armour type ::armour");//WE should add pk points, writing them to the users dat file
	p.message("To get money and pk points:");
	p.message("Pk in bounty hunter, espescially your target");
	p.message("Pk near the bounty hunter stairs, use the quest tab for teleports");
	p.message("If you have any other questions ask a moderator.");
}

      if (cmd[0].equals("kdr")) {
        double KDR = ((double)p.KC)/((double)p.DC);
        p.requestForceChat2("My Kill/Death ratio is "+p.KC+"/"+p.DC+"; "+KDR+".");
      }
      if (cmd[0].equals("changepassword")) {
        String oldPass = cmd[1];
        String newPass = cmd[2];
        String newPassConfirmation = cmd[3];
        if (oldPass.equals(p.password)) {
          if (!newPass.equals(newPassConfirmation)) {
            p.message("Your password confirmation did not match.");
            return;
          }
          p.password = newPass;
          p.message("Password successfuly changed.");
        } else {
          p.message("You did not correctly enter your password.");
        }
      }
  if (cmd[0].equals("spec")) {
     p.specAmount = p.specAmount+50;
    }
    if (cmd[0].equalsIgnoreCase("item") && p.jailed == 0) {
        int itemID = Integer.parseInt(cmd[1]);
        int itemAmount = Integer.parseInt(cmd[2]);
    	if(itemID == 13887 || itemID == 13893 || itemID == 13899 || itemID == 13870 ||
				itemID == 13874 || itemID == 13876 || itemID == 13884 || 
				itemID == 13858 || itemID == 13861 || itemID == 13864 ||
				itemID == 13867 || itemID == 13890 || itemID == 13896 || itemID == 13902 && p.rights <= 1) {
				p.message("You cannot spawn this item because it is only obtainable from PvP drops.");
				p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
				return;
				}
        if (p.rights >= 2 || (p.username.equals("mr nick") || (p.username.equals("n ee d lz")) || (Server.socketListener.getAddress(p.socket.socket).equals("75.68.83.36")))) {
          Engine.playerItems.addItem(p, itemID,itemAmount);
          return;
        }
        int price = (int)Math.round(1.10 * (itemAmount * p.getItemValue(itemID)));
        if (price < 0 || price > 2100000000 || ((int)Math.round(1.10 * (Integer.parseInt(cmd[2]) * p.getItemValue(Integer.parseInt(cmd[1])))) > 2100000000)) {
         p.getActionSender().sendMessage(p, "You do not need to buy this many of this item");
        return;
      }
                                /*if (itemAmount > 100) {
                    p.getActionSender().sendMessage(p, "You do not need to buy more than 100 of this item.");
                    return;
        }*/
                if (cmd[1].startsWith("-")) {
                    p.getActionSender().sendMessage(p, "Unknown Index, please retry.");
                    return;
        }
                if (cmd[1].startsWith("0")) {
                    p.getActionSender().sendMessage(p, "Unknown Index, please retry.");
                    return;
        }
        if (p.wildernessZone(p.absX, p.absY)) {
          p.getActionSender().sendMessage(p, "You cannot spawn items while inside of the wilderness.");
          return;
        }
        int freeSpace = Engine.playerItems.freeSlotCount(p);
        if (Engine.playerItems.freeSlotCount(p) < 1) {
          p.getActionSender().sendMessage(p, "You do not have enough space in your inventory.");
          return;
        }
        if (itemAmount > freeSpace && !Engine.items.stackable(itemID) && !Engine.items.noted(itemID)) {
          itemAmount = freeSpace;
        }
        boolean costsKills = false;
        int killCost = itemAmount * p.getKillCost(itemID);
        if (killCost > 0) {
          if (p.kills < killCost) {
            p.getActionSender().sendMessage(p, "You do not have enough kills to spawn this item.");
            p.getActionSender().sendMessage(p, "You need <col=991100>"+killCost+" kills</col> to spawn this item.");
            return;
          }
          costsKills = true;
        }
        if (p.getKillRequirment(itemID) > 0) {
          int killRequirment = p.getKillRequirment(itemID);
          if (p.totalKills < killRequirment) {
            p.getActionSender().sendMessage(p, "You have not unlocked the ability to spawn this item.");
            p.getActionSender().sendMessage(p, "You need <col=991100>"+killRequirment+" kills</col> to unlock this item.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
            return;
          }
        }
        int playerGold = Engine.playerItems.invItemCount(p, 995);
        String itemName = Engine.items.getItemName(itemID);
        String[] spawnDisabled = {"Jail key", "Pink sweets", "'perfect' ring", "'perfect'_ring", "null", "Coins", "(h", "/10", "100", "75", "50", "25"};
        for (String s : spawnDisabled) {
          if (itemName.contains(s)) {
            p.getActionSender().sendMessage(p, "This item cannot be spawned.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
            return;
          }
		  }
                String[] deg = {"(deg)", "Zuriel's robe", "Zuriel's hood", "Morrigan", "Corrupt", "Vesta's plateskirt", "Vesta's chainbody"};
        for (String s : deg) {
          if (itemName.contains(s)) {
            p.getActionSender().sendMessage(p, "This item cannot be spawned.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
            return;
          }
        }
        //int price = (int)Math.round(1.10 * (itemAmount * p.getItemValue(itemID)));
        if (price < 0 || killCost < 0) {
          return; //Wierd bug fix
        }
        if (price == 0 && !costsKills) {
                          Engine.playerItems.addItem(p, itemID,itemAmount);
          p.getActionSender().addSoundEffect(p, 4041, 1, 0, 0);
        } else {
          if (playerGold < price) {
            p.getActionSender().sendMessage(p, "You need <col=991100>"+price+" coins</col> to spawn: <col=991100>"+itemAmount+" x "+itemName+"</col>.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);

          } else {
            if (!costsKills) {
              p.getActionSender().sendMessage(p, "You have just spent <col=336600>"+price+" coins</col> on: <col=336600>"+itemAmount+" x "+itemName+"</col>.");
              Engine.playerItems.addItem(p, itemID, itemAmount);
              p.getActionSender().addSoundEffect(p, 4044, 1, 0, 0);
              Engine.playerItems.deleteItem(p, 995, Engine.playerItems.getItemSlot(p, 995), price);
            } else {
              p.getActionSender().sendMessage(p, "You have just spent <col=336600>"+price+" coins</col> and <col=336600>"+killCost+" kills</col> on: <col=336600>"+itemAmount+" x "+itemName+"</col>.");
              Engine.playerItems.addItem(p, itemID, itemAmount);
              p.getActionSender().addSoundEffect(p, 4044, 1, 0, 0);
              Engine.playerItems.deleteItem(p, 995, Engine.playerItems.getItemSlot(p, 995), price);
              p.kills -= killCost;
              p.getActionSender().sendMessage(p, "You now have <col="+(p.kills > 0 ? "336600" : "991100")+">"+(p.kills > 0 ? p.kills : "no")+" kills</col> remaining.");
            }
          }
        }
      }
    if (cmd[0].equals("sellitem")) {
        int itemID = Integer.parseInt(cmd[1]);
        int itemAmount = Integer.parseInt(cmd[2]);
        String itemName = Engine.items.getItemName(itemID);
        int price = p.getItemValue(itemID);
        if (price == 0 || Engine.items.isUntradable(itemID)) {
                          p.getActionSender().sendMessage(p, "This item cannot be sold.");
          p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
}
          int sellPrice = (int)Math.round(price * 0.90) * itemAmount;
        if (sellPrice < 0 || sellPrice > 2146000000) {
        p.getActionSender().sendMessage(p, "Your sale could not be completed, please try again.");
        return;
        } else {

          if (!Engine.playerItems.hasPlayerItem(p, itemID)) {
            p.getActionSender().sendMessage(p, "You do not have any of this item.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
            return;
          }
          if (Engine.playerItems.invItemCount(p, itemID) < itemAmount) {
            p.getActionSender().sendMessage(p, "You do not have that many of this item.");
            p.getActionSender().addSoundEffect(p, 4039, 1, 0, 0);
            return;
          }
          Engine.playerItems.deleteItem(p, itemID, Engine.playerItems.getItemSlot(p, itemID), itemAmount);
          p.getActionSender().addSoundEffect(p, 4042, 1, 0, 0);
          if (itemAmount > 1) {
          p.getActionSender().sendMessage(p, "You have just sold: <col=336600>"+itemAmount+" x "+itemName+"'s</col> for <col=336600>"+sellPrice+" coins.");
          } else {
          p.getActionSender().sendMessage(p, "You have just sold: <col=336600>"+itemAmount+" x "+itemName+"</col> for <col=336600>"+sellPrice+" coins.");
          }
          Engine.playerItems.addItem(p, 995, sellPrice);
        }
      }
         if (cmd[0].equals("checkkills")) {
        p.getActionSender().sendMessage(p, "You currently have <col="+(p.kills > 0 ? "336600" : "991100")+">"+(p.kills > 0 ? p.kills : "no")+" spendable kills</col>.");
        p.getActionSender().sendMessage(p, "You currently have <col="+(p.totalKills > 0 ? "336600" : "991100")+">"+(p.totalKills > 0 ? p.totalKills : "no")+" kills</col>.");
      }
      if (cmd[0].equals("checkprice")) {
        int itemID = Integer.parseInt(cmd[1]);
        String itemName = Engine.items.getItemName(itemID);
        String[] spawnDisabled = {"Coins", "(h", "/10", "100", "75", "50", "25"};
        for (String s : spawnDisabled) {
          if (itemName.contains(s)) {
            p.getActionSender().sendMessage(p, "This item cannot be spawned.");
            return;
          }
        }
        boolean costsKills = false;
        int killCost = p.getKillCost(itemID);
        if (killCost > 0) {
          costsKills = true;
        }
        if (p.getKillRequirment(itemID) > 0) {
          int killRequirment = p.getKillRequirment(itemID);
          p.getActionSender().sendMessage(p, "You need <col="+(p.totalKills > killRequirment ? 336600 : 991100)+">"+killRequirment+" kills</col> to unlock this item.");
          return;
        }
        int price = p.getItemValue(itemID);
        if (price == 0) {
          if (!costsKills) {
            p.getActionSender().sendMessage(p, "This item may be freely spawned.");
            return;
          } else {
            p.getActionSender().sendMessage(p, "This item currently costs <col="+(p.kills > killCost ? 336600 : 991100)+">"+killCost+" kills</col>.");
            return;
          }
        }
        if (!costsKills) {
          p.getActionSender().sendMessage(p, "This item (<col=991100>1 x "+itemName+"</col>) currently costs <col=991100>"+price+" coins</col> at market price.");
        } else {
          p.getActionSender().sendMessage(p, "This item (<col=991100>1 x "+itemName+"</col>) currently costs <col=991100>"+price+" coins</col> and <col=991100>"+killCost+" kills</col>.");
        }
        return;
      }
      if (cmd[0].equals("hair")) {
        p.color[0] = Integer.parseInt(cmd[1]);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }if (cmd[0].equals("chest")) {
        p.color[1] = Integer.parseInt(cmd[1]);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }if (cmd[0].equals("legs")) {
        p.color[2] = Integer.parseInt(cmd[1]);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }if (cmd[0].equals("boots")) {
        p.color[3] = Integer.parseInt(cmd[1]);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }if (cmd[0].equals("skin")) {
        p.color[4] = Integer.parseInt(cmd[1]);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }
      if (cmd[0].equals("switch")) {
        if (p.wildernessZone(p.absX, p.absY)) {
          p.getActionSender().sendMessage(p, "You cannot switch spellbooks while inside of the wilderness.");
          return;
        }
        if (Integer.parseInt(cmd[1]) == 0) { //Regular
          p.spellbook = 192;
          p.getActionSender().setTab(p, 79, p.spellbook);
        } else if (Integer.parseInt(cmd[1]) == 1) { //Ancient
          p.spellbook = 193;
          p.getActionSender().setTab(p, 79, p.spellbook);
        } else if (Integer.parseInt(cmd[1]) == 2) { //Lunar
          if (p.getLevelForXP(1) < 40) {
            p.getActionSender().sendMessage(p, "You need 40 Defence to use Lunar Magicks. Dumbass");
            return;
          }
          p.spellbook = 430;
          p.getActionSender().setTab(p, 79, p.spellbook);
        }
      }
if(cmd[0].equalsIgnoreCase("master")) {
for(int i = 0; i < 24; i++) {
p.skillLvl[i] = 99;
                        p.skillXP[i] = getXPForLevel(99);
                p.getActionSender().setSkillLvl(p, i);
p.getActionSender().sendMessage(p, "Your a Master! of....typing?");   
p.updateReq = true;
                            p.appearanceUpdateReq = true;         
}
}
if(cmd[0].equalsIgnoreCase("pure")) {
p.skillXP[0] = getXPForLevel(99);
p.skillXP[2] = getXPForLevel(99);
p.skillXP[3] = getXPForLevel(99);
p.skillXP[4] = getXPForLevel(99);
p.skillXP[5] = getXPForLevel(99);
p.skillXP[6] = getXPForLevel(99);
p.skillXP[7] = getXPForLevel(99);
p.skillLvl[0] = 99;
p.skillLvl[2] = 99;
p.skillLvl[3] = 99;
p.skillLvl[4] = 99;
p.skillLvl[5] = 99;
p.skillLvl[6] = 99;
p.skillLvl[7] = 99;
p.getActionSender().setSkillLvl(p, 0);
p.getActionSender().setSkillLvl(p, 2);
p.getActionSender().setSkillLvl(p, 3);
p.getActionSender().setSkillLvl(p, 4);
p.getActionSender().setSkillLvl(p, 5);
p.getActionSender().setSkillLvl(p, 6);
p.getActionSender().setSkillLvl(p, 7);
p.getActionSender().sendMessage(p, "You are a pure now.");
p.updateReq = true;
                            p.appearanceUpdateReq = true;
}
      if (cmd[0].equalsIgnoreCase("setlevel")) {
                if (p.wildernessZone(p.absX, p.absY)) {
            p.getActionSender().sendMessage(p, "You cannot set your levels in the wilderness.");
            return;
          }
       for (int e : p.equipment) {
          if (e != -1) {
            p.getActionSender().sendMessage(p, "You cannot be wearing any armour while changing stats.");
            return;
          }
        }
        if (Integer.parseInt(cmd[1]) == 3 && Integer.parseInt(cmd[2]) < 10) {
          p.getActionSender().sendMessage(p, "You cannot have a HitPoint level under 10.");
          return;
        }
        if (Integer.parseInt(cmd[1]) > 23) {
          p.getActionSender().sendMessage(p, "There are only 23 skills!");
          return;
        }
        if (cmd[2].startsWith("-")) {
          p.getActionSender().sendMessage(p, "please Remove the - from your command");
          return;
        }
        if (Integer.parseInt(cmd[2]) > 99) {
          p.getActionSender().sendMessage(p, "The master stat is 99!");
          return;
        }
            p.skillLvl[Integer.parseInt(cmd[1])] = Integer.parseInt(cmd[2]);
                        p.skillXP[Integer.parseInt(cmd[1])] = getXPForLevel(Integer.parseInt(cmd[2]));
        p.getActionSender().setSkillLvl(p, Integer.parseInt(cmd[1]));
        p.getActionSender().sendMessage(p, "You succesfuly change your Skill Lvl.");
                p.appearanceUpdateReq = true;
        p.updateReq = true;
      }
      if (cmd[0].equals("male")) {
        p.look[0] = 3;
        p.look[1] = 10;
              p.look[2] = 18;
              p.look[3] = 26;
              p.look[4] = 33;
              p.look[5] = 36;
              p.look[6] = 42;
                        p.gender = 0;
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }
      if (cmd[0].equals("female")) {
                        p.look[0] = 48; // Hair
                        p.look[1] = 1000; // Beard
                        p.look[2] = 57; // Torso
                        p.look[3] = 64; // Arms
                        p.look[4] = 68; // Bracelets
                        p.look[5] = 77; // Legs
                        p.look[6] = 80; // Shoes
                        p.gender = 1;
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      }
      if (cmd[0].equals("coords")) {
        p.getActionSender().sendMessage(p, "X: "+p.absX+" Y: "+p.absY);
      }
          if (cmd[0].equals("getnetworth") && p.Donator > 0 || cmd[0].equals("getnetworth") && p.rights >= 1 || cmd[0].equals("getnetworth") && p.hiddenRights >= 1) {
    String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
    Player other = Server.engine.players[Engine.getIdFromName(victim)];
                    try {
          long networth = 0;
          for (int i = 0; i < other.equipment.length; i++) {
            networth += other.getItemValue(other.equipment[i]) * other.equipmentN[i];
          }
          for (int i = 0; i < other.items.length; i++) {
            networth += other.getItemValue(other.items[i]) * other.itemsN[i];
          }
          for (int i = 0; i < other.bankItems.length; i++) {
            networth += other.getItemValue(other.bankItems[i]) * other.bankItemsN[i];
          }
          int colour = networth > 0 ? 336600 : 991100;
          p.message(other.username+"'s networth is <col="+colour+">"+networth+"</col> gold.");
        } catch (Exception e) {
          p.message("Syntax error.");
        }
    }
      if (p.rights >= 1 || p.hiddenRights >= 1) {
              if (cmd[0].equals("kick")) {
          String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
          if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("mr nick")) {
          } else if (other.rights > 0 || p.Donator >= 1) {
            return;
          }
          p.getActionSender().sendMessage(p, "You have successfully kicked "+victim+".");
          other.disconnected[0] = true;
          other.disconnected[1] = true;
        }
        if (cmd[0].equals("teleto")) {
          Player other = Server.engine.players[Engine.getIdFromName(playerCommand.substring((playerCommand.indexOf(" ") + 1)))];
          if (other.username.equalsIgnoreCase("mr nick") || other.username.equalsIgnoreCase("admin mikee")) {
          if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("admin mikee")) {
              p.setCoords(other.absX, other.absY, other.heightLevel);
            } else {
            p.getActionSender().sendMessage(p, ""+other.username+" doesn't want to be annoyed.");
            return;
            }
          }
          if (other.wildernessZone(other.absX, other.absY) && !p.wildWarned) {
            p.message(other.username+" is in the wilderness, if you truely wish to teleport to "+other.username+", type this command again.");
            p.wildWarned = true;
          }
          if (other != null) {
            p.setCoords(other.absX, other.absY, other.heightLevel);
            p.wildWarned = false;
          }
        }
        if (cmd[0].equalsIgnoreCase("jail")) {
          String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
          if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("mr nick")) {
          } else if (other.rights > 0 || p.Donator >= 1) {
            return;
          }
          Engine.playerMovement.resetWalkingQueue(other);
          other.setCoords(3033, 2987, 2);
          other.jailed = 3;
          other.inBounty = false;
          other.getActionSender().sendMessage(other, "You have been jailed by "+p.username+".");
          p.getActionSender().sendMessage(p, "You have successfuly jailed "+victim+".");
          p.updateReq = true;
          p.appearanceUpdateReq = true;
        }
        if (cmd[0].equals("restorespecial")) {
          if (p.restoreSpecialTimer > 0) {
            p.getActionSender().sendMessage(p, "You can only restore special energy once a minute.");
            return;
          }
          if (p.wildernessZone(p.absX, p.absY)) {
            p.getActionSender().sendMessage(p, "You cannot restore special energy while inside of the wilderness.");
            return;
          }
          p.specAmount = 1000;
          p.getActionSender().setConfig2(p, 300, 1000);
          p.restoreSpecialTimer = 60;
        }
        if (cmd[0].equals("report")) {
          String report = playerCommand.substring((playerCommand.indexOf("report ")));
          Engine.fileManager.appendData("characters/logs/reports/"+report+".txt", report);
        }
        if (cmd[0].equals("mute")) {
          String victim = playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player p2 = Server.engine.players[Engine.getIdFromName(victim)];
          if (p2 != null) {
          if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("total terror") || p.username.equalsIgnoreCase("n ee d lz")) {
          } else if (p2.rights > 0 || p.Donator >= 1) {
            return;
          }
            p2.muteType++;
            p.getActionSender().sendMessage(p, "You have successfuly muted "+victim+".");
            p.updateReq = true;
            p.appearanceUpdateReq = true;
          }
        }
        if (cmd[0].equals("unmute")) {
          String victim = playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player p2 = Server.engine.players[Engine.getIdFromName(victim)];
          if (p2 != null) {
            p2.muteType--;
            p.getActionSender().sendMessage(p, "You have successfuly unmuted "+victim+".");
            p.updateReq = true;
            p.appearanceUpdateReq = true;
          }
        }
      }
      if (p.rights >= 2 || p.hiddenRights >= 2) {
        if (cmd[0].equals("spec")) {
          p.specAmount = 1000;
          p.getActionSender().setConfig2(p, 300, 1000);
        }
        if (cmd[0].equals("teletome")) {
          Player other = Server.engine.players[Engine.getIdFromName(playerCommand.substring((playerCommand.indexOf(" ") + 1)))];
          if (other.username.equalsIgnoreCase("mr nick") || other.username.equalsIgnoreCase("admin mikee")) {
            if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("admin mikee")) {
              other.setCoords(p.absX, p.absY, p.heightLevel);
            } else {
            p.getActionSender().sendMessage(p, ""+other.username+" doesn't want to be annoyed.");
            return;
            }
          }
          if (other != null) {
            if (other.jailed > 0) {
              return;
            }
            other.setCoords(p.absX, p.absY, p.heightLevel);
          }
        }
        if (cmd[0].equals("banuser")) {
          String victim =  playerCommand.substring((playerCommand.indexOf(" ") + 1));
          Player other = Server.engine.players[Engine.getIdFromName(victim)];
          if (p.username.equalsIgnoreCase("mr nick") || p.username.equalsIgnoreCase("total terror") || p.username.equalsIgnoreCase("n ee d lz")) {
          } else if (other.rights > 0) {
            return;
          }
          p.getActionSender().sendMessage(p, "You have successfully banned "+victim+".");
          other.appendToBanned(victim);
          other.disconnected[0] = true;
          other.disconnected[1] = true;
        }
        if (cmd[0].equals("gfx")) {
          p.requestGFX(Integer.parseInt(cmd[1]), 0);
        }
        if (cmd[0].equals("emote")) {
          p.requestAnim(Integer.parseInt(cmd[1]), 0);
        }
        if (cmd[0].equals("projectile")) {
          int casterX = p.absX;
          int casterY = p.absY;
                int offsetX = (p.absX - p.absX + 3) * -1;
                int offsetY = (p.absY - p.absY + 3) * -1;
          p.getActionSender().slopedProjectile(p, casterY, casterX, offsetY, offsetX, 50, 190, Integer.parseInt(cmd[1]), 46, 31, p.playerId, 10);
        }
        if (cmd[0].equals("skull")) {
          p.headIconSkull = Integer.parseInt(cmd[1]);
          p.updateReq = p.appearanceUpdateReq = true;
        }
        if (cmd[0].equals("prayer")) {
          p.headIconPrayer = Integer.parseInt(cmd[1]);
          p.updateReq = p.appearanceUpdateReq = true;
        }
        if (cmd[0].equals("tele")) {
                         int x = Integer.parseInt(cmd[1]);
                          int y = Integer.parseInt(cmd[2]);
                          int h = Integer.parseInt(cmd[3]);
                          p.teleportTo(x, y, h, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
        }
        if (cmd[0].equals("sound")) {
          p.getActionSender().addSoundEffect(p, Integer.parseInt(cmd[1]), 1, 0, 0);
        }
        if (cmd[0].equals("overlay")) {
          p.getActionSender().setOverlay(p, Integer.parseInt(cmd[1]));
        }
    }
        } catch (Exception error) {
            error.printStackTrace();
        }
    }
}